﻿<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>驰骋工作流引擎登录</title>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <link href="../Style/skin/css/login.css" rel="stylesheet" type="text/css" />
    <link href="../Scripts/bootstrap/css/bootstrap.css" rel="stylesheet" type="text/css" />
    <script src="../Comm/JS/validation.js"></script>
    <script type="text/javascript" language="javascript">
        document.onkeydown = function (e) {
            e = e || window.event;
            if (e.keyCode == 13) {

                Login();
                return false;
                //this.forms["Form1"].submit();
                //return false;
            }
        }
    </script>
</head>
<body class="login-bg">
    <div class="login-box">
        <h1 class="logo-name">
            驰骋工作流引擎登录</h1>
        <div class="login-form">
            <form id="Form1">
                <div class="form-group">
                    <input type="text" id="TB_No" name="TB_No" placeholder="请输入账号" lay-verify="required"
                           class="form-control" />
                </div>
                <div class="form-group">
                    <input type="password" id="TB_PW" name="TB_PW" placeholder="请输入密码" lay-verify="required"
                           class="form-control" />
                </div>
                <div id="validate" class="form-group" style="display: none">

                    <input type="text" class="form-control" placeholder="验证码" id="inputCode" style="width:50%;display: inline" />
                    <canvas id="canvas" width="78" height="24"></canvas>
                    <a href="javascript:void(0)" style="margin-left: 10px" onclick="createCode()">看不清</a>
                </div>
                <input type="button" class="btn btn-primary btn-block" value="操作员登录" lay-submit lay-filter="formDemo" />
            </form>
            <div class="row login-nav">
                <div class="col-xs-6">
                    默认密码：123</div>
                <div class="col-xs-6 ">
                    <a href="../Admin/CCBPMDesigner/Login.htm" class="pull-right">流程设计器</a> <a href="http://ccbpm.mydoc.io"
                        target="_blank" class="pull-right">帮助文档&nbsp;&nbsp;</a>
                </div>
            </div>
        </div>
    </div>
    <script src="../Style/skin/layui/layui.js" type="text/javascript"></script>
    <script src="../Scripts/jquery/jquery.min.js" type="text/javascript"></script>
    <!-- 引用通用的js文件. -->
    <script src="../Scripts/QueryString.js"></script>
    <script type="text/javascript" src="../Scripts/config.js"></script>
    <script type="text/javascript" src="../Comm/Gener.js"></script>
    <script type="text/javascript" language="javascript">
        //页面启动函数.

        layui.use(['form', 'layer'], function () {

            //从后台获取当前登录会话的信息.
            var handler = new HttpHandler("BP.WF.HttpHandler.WF_AppClassic");
             var doType = GetQueryString("DoType");
            if (doType != null && doType != undefined && doType != "")
                handler.AddPara("LoginType", doType);
            var data = handler.DoMethodReturnString("Login_Init");
            if (data.indexOf('err@') == 0) {
                alert(data);
                return;
            }
            data = JSON.parse(data);

            //调用公共类库的方法:执行批量主表赋值
            GenerFullAllCtrlsVal(data);

            var userNo = document.getElementById("TB_No").value;
            if (userNo == "")
                document.getElementById("TB_PW").value = "";

            var form = layui.form, layer = layui.layer, $ = layui.jquery;
            form.on('submit(formDemo)', function (data) {

                Login();

            })
        });

        function Login() {

            var userNo = $("#TB_No").val();
            var userPass = $("#TB_PW").val();

            if (userNo == "" || userPass == "") {
                layer.msg('请输入用户名与密码');
                return false;
            }
            //判断验证码是否正确
            var node = $("#validate");
            if(node.is(':visible'))
            {
                if (!validateCode()) {
                    return;
                }
            }

            //创建handler实体. 
            var handler = new HttpHandler("BP.WF.HttpHandler.WF_AppClassic");
            //加入参数.
            handler.AddPara("TB_No", userNo); 
            handler.AddPara("TB_PW", userPass);
            //调用服务.
            var data = handler.DoMethodReturnString("Login_Submit");
            //分析处理返回值.
            if (data.indexOf('err@') == 0) {
                alert(data);
                return;
            }


            if (data.indexOf('err@') == 0) {
                layer.msg(data, { time: 3000, icon: 2 });
                $("#validate").show();
                createCode();
                return;
            }

            layer.msg(data, { time: 10, icon: 1 }, function () {
                location.href = 'Home.htm';
            });
        }
        
    </script>
</body>
</html>
